package tmproject.hlhj.fhp.cartrans

import android.annotation.SuppressLint
import android.os.Build
import android.os.Bundle
import android.view.View
import android.widget.TextView
import com.example.mymvp.BaseMvpAty
import com.example.mymvp.BasePresenter
import com.example.mymvp.BaseView
import com.gyf.barlibrary.ImmersionBar
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
import tmproject.hlhj.fhp.cartrans.customVIews.LoadingDialog
import tmproject.hlhj.fhp.cartrans.utils.LoadingUtil

/**
 * Created by Never Fear   on 2018\8\10 0010.
Never More....
 */
 abstract class BaseAty<V: BaseView,P: BasePresenter<*, V>>: BaseMvpAty<V, P>(){
    private var  compositeDisable:CompositeDisposable?=null
    @SuppressLint("MissingSuperCall")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getContentId())
        supportActionBar?.hide()
        presenter?.initView()
        presenter?.setListener()
        presenter?.logicStart()
        ImmersionBar.with(this)
                .statusBarDarkFont(true)
                .init()
        val headDv = findViewById<TextView>(R.id.headDv)
        if (headDv!=null){
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){
                headDv.visibility=View.GONE
            }else{
                headDv.visibility=View.VISIBLE

            }
        }
    }
    open fun addDisable(disable: Disposable){
        if (compositeDisable==null){
            compositeDisable= CompositeDisposable()
        }
        compositeDisable?.add(disable)
    }
    abstract fun getContentId(): Int
    @SuppressLint("MissingSuperCall")
    override fun onDestroy() {
        compositeDisable?.dispose()
        LoadingUtil.hideLoading()
        super.onDestroy()
    }
}